<?php
/**
 * Terrafirma :: Extensive pattern & component framework
 * Copyright 2010-2011 Ian Unruh (Xerof3ar)
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
namespace Terrafirma\Event\Hub;

use Countable;
use IteratorAggregate;
use Terrafirma\Event\EventInterface;

/**
 * A repository stores subscribers for a hub and determines which ones
 * will be notified of certain events
 * 
 * The interface purposely leaves out methods dealing with registration and
 * unregistration of subscribers, because the way in which subscribers
 * are stored is left up to the implementations in the interests of efficiency.
 * 
 * @author Ian Unruh (Xerof3ar) <ianunruh@gmail.com>
 * @since Class avaliable since version 1.0
 */
interface RepositoryInterface extends Countable, IteratorAggregate
{
	/**
	 * Clears all subscribers from this repository
	 * @return void
	 */
	public function clear();
	
	/**
	 * Returns all subscribers stored in this repository
	 * @return ArrayObject<SubscriberInterface>
	 */
	public function getAll();
	
	/**
	 * Returns all subscribers that should be notified of a given event
	 * 
	 * @param EventInterface $event
	 * @return ArrayObject<SubscriberInterface>
	 */
	public function getAllByEvent(EventInterface $event);
}